package com.ada.spark.rddoperator

import org.apache.spark.{SparkConf, SparkContext}

/**
  * 作用：对源RDD和参数RDD求交集后返回一个新的RDD
  */
object Spark16_intersection {

    def main(args: Array[String]): Unit = {
        //创建SparkConf
        val conf = new SparkConf().setAppName("Spark16_intersection").setMaster("local[*]")
        //创建Spark上下文对象
        val sc = new SparkContext(conf)

        val rdd1 = sc.parallelize(1 to 7)

        val rdd2 = sc.parallelize(5 to 10)

        //取交集
        val rdd3 = rdd1.intersection(rdd2)

        println(rdd3.collect().mkString(","))
        //5,6,7
    }

}
